package com.demo.morning;

/**
 * @ClassName 静态代理模式
 * @Description TODO
 * @Author tianqinglong
 * @Date 9:45 2022/7/13
 * @Version 1.0
 **/
public class 静态代理模式 {
    public static void main(String[] args) {
//        new Thread(()-> System.out.println("我爱你")).start();
        new WeddingCompany(new You()).HappyMarry();

        WeddingCompany w = new WeddingCompany(new You());
        w.HappyMarry();
    }
}
interface Marry {
    void HappyMarry();
}
//真实角色
class You implements Marry {

    @Override
    public void HappyMarry() {
        System.out.println("张三要结婚了，超开心");
    }

}//代理角色
class WeddingCompany implements Marry {
    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }

    private void before() {
        System.out.println("布置现场");
    }

    private void after() {
        System.out.println("收尾款");
    }
}